package com.snowy.hidden.biz.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 审核结果枚举
 * @author hjl
 */
@Getter
@AllArgsConstructor
public enum TaskCurrentStatusEnum {

    //已发布
    RELEASED(0,"已发布"),
    //待执行
    WAIT_EXECUTE(1,"待执行"),
    //执行中
    EXECUTING(2,"执行中"),
    //执行完成
    FINISHED(3,"执行完成"),
    //已经失败
    FAILED(4,"已经失败"),
    //未知状态
    UNKNOW(99,"未知"),
    ;

    /**
     * 值
     */
    private Integer value;
    /**
     * 描述
     */
    private String desc;

    public static TaskCurrentStatusEnum findByValue(Integer val) {
        return Arrays.stream(TaskCurrentStatusEnum.values()).filter(item -> Objects.equals(val, item.getValue())).findFirst().orElse(UNKNOW);
    }

    public static String getNameByValue(Integer val) {
        return Arrays.stream(TaskCurrentStatusEnum.values()).filter(item -> Objects.equals(val, item.getValue())).findFirst().orElse(UNKNOW).getDesc();
    }
}
